package com.ibeetl.cms.service;

import java.util.List;

import com.ibeetl.cms.entity.Quit;
import com.ibeetl.cms.entity.Renting;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ibeetl.admin.core.util.PlatformException;

import com.ibeetl.cms.dao.EntryDao;
import com.ibeetl.cms.entity.Entry;
import com.ibeetl.admin.core.service.BaseService;

/**
 * Entry Service
 */

@Service
@Transactional
public class EntryService extends BaseService<Entry>{

    @Autowired
    private EntryDao entryDao;

    public PageQuery<Entry>queryByCondition(PageQuery query){
        PageQuery ret =  entryDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelEntry(List<Long> ids){
        try {
            entryDao.batchDelEntryByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除Entry失败", e);
        }
    }
    //查企业
    public PageQuery<Entry>findenterprise(PageQuery query){
        PageQuery ret =  entryDao.findenterprise(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public PageQuery<Entry> queryDoneTask(PageQuery page) {
        PageQuery ret =  entryDao.queryDoneTask(page);
        queryListAfter(ret.getList());
        return ret;

    }

    public Boolean updateCompanyId(Integer companyId,Integer userId){
        return entryDao.updateCompanyId(companyId,userId)>0;
    }

    public Boolean updateEssentialInformation(Integer companyId,String currentWorkingEnterprise,Integer userId){
        return entryDao.updateEssentialInformation(companyId,currentWorkingEnterprise,userId)>0;
    }
}